package com.example.exception.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;

@Controller
public class ClassAndIoController {

    @RequestMapping("/downloadFile")
    public String downloadFile() throws IOException {
        FileInputStream fileInputStream = new FileInputStream("/usr/local/tomcat");
        return "/homePage";
    }

    /**
     * 获取不存在的类
     *
     * @return
     * @throws ClassNotFoundException
     */
    @GetMapping("getClassOfDoesNotExist")
    public String getClassOfDoesNotExist() throws ClassNotFoundException {
        Class<?> aClass = Class.forName("com.example.exception.doesNotExist");
        return "/homePage";
    }
}
